<?
include_once("/var/www/html/new/d/yd/client/header_n.php");
include_once("/var/www/html/new/d/common/page.php");
include_once("/var/www/html/new/d/yd/OrderRecord.php");
include_once("/var/www/html/new/d/class/ProOrder.php");
// include_once("/var/www/html/new/conf/yd.le.je");
// include_once("/var/www/html/new/d/common/yd.le.je");
// $ydle=new yd_go_sql();
// $ydle->connect(); 
$ac=$GLOBALS['_ac'];
$pw=$GLOBALS['_pw'];
$s = new SoapClient(null,array("location" => "http://localhost/open/openService/pft_insideMX.php","uri" => "www.16u.com?ac_16u=$ac|pw_16u=$pw|auth_16u=true"));
$memberID = $_SESSION['sid'];
$_REQUEST['begintime']='2014-12-07 00:00:00';
$_REQUEST['endtime']=date('Y-m-d H:i:s');
$currentPage = $_REQUEST["currentPage"]?$_REQUEST["currentPage"]:1;
$pageSize = $_REQUEST['pageSize']?$_REQUEST["pageSize"]:5;
// print_r($_SESSION);

$pOrder=buyProOrderObject($memberID,$s,$_SESSION['sdtype']);
$r=$pOrder->_orderlist($currentPage,$pageSize);
// print_r($r);
// 判断订单是否为主订单  true为主订单
function isMainOrder($field){
	return ($field=='main' || $field!=0 ) ? true:false;
}
// 复票订单主订单
function echoMainOrder($obj){
	return ((String)$obj->UUconcat_id=='main') ? (String)$obj->UUordernum:(String)$obj->UUconcat_id;
}
$count=$pOrder->orderlistTotal();
$uuStatus = array(
    0=>"未使用",
    1=>"<em class='green'>已使用</em>",
    2=>"已过期",
    3=>"<em class='red'>已取消</em>",
    4=>"被替代",
    5=>"<em class='green'>已使用</em><br/><em class='red'>(被修改)</em>",
    6=>"已撤销",
    7=>"部分使用"
);
// $orderxml = $s->Order_Globle_Search('',$memberID,'','','','','','','','','','','','', '', '0|1|2|3|4|5|6',  '0|1|2', '', '', 1, 0, 15, 0, 1, '', 0, '',0, '','' ,'', 0, 0);
// $r = simplexml_load_string($orderxml);
// $concat=0;
// print_r($r);
?>
<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7 ie6"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8 ie7"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9 ie8"> <![endif]-->
<!--[if gt IE 8]><!--> <html> <!--<![endif]-->
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<meta charset="UTF-8"/>
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="description" content=""/>
	<meta name="keywords" content=""/>
	<link rel="stylesheet" href="http://www.12301.cc/shops/css/base.css"/>
	<link rel="stylesheet" href="http://www.12301.cc/shops/css/global.css"/>
	<link rel="stylesheet" type="text/css" href="http://www.12301.cc/css/page.css"/>
	<link rel="stylesheet" href="http://www.12301.cc/shops/css/gmem.css"/>
	<link type="text/css" rel="stylesheet" href="http://yd.12301.cc/css/yunding/mem.css">
	<script language="javascript" src="http://yd.12301.cc/js/yunding/common/jquery-1.8.3.min.js"></script>
	<!--[if lt IE 10]>
		<script type="text/javascript" src="http://www.12301.cc/shops/js/PIE.js"></script>
	<![endif]
	<script language="javascript">
	$(function() {
		if (window.PIE) {
			$('.rounded').each(function() {
				PIE.attach(this);
			});
		}
	});
	</script>-->
	<title>首页</title>
</head>
<body>
	<div id="ggHeader" class="ggHeader"><div class="customCon"><img src="http://www.12301.cc/shops/images/gulangyun_logo_banner.jpg" alt=""/></div></div>
	<div id="ggNavbar" class="ggNavbar">
		<div class="con ggw1100">
			<ul class="navUl ggw1100 clearfix">
				<li class="navLi"><a href="#">首页</a></li>
				<li class="navLi"><a href="#">票务预订</a></li>
				<li class="navLi"><a href="#">酒店预订</a></li>
				<li class="navLi"><a href="#">旅游路线</a></li>
			</ul>
			<div id="ggUserbar" class="ggUserbar gsprite">
				<div class="fl col l">
					<i class="gsprite gicon user"></i>
					<a id="loginBtn" class="loginBtn t" href="#">登录</a>
					<a id="siginBtn" class="siginBtn t" href="#">注册</a>
				</div>
				<a href="#" class="fl col r">
					<span id="topCarticon" class="topCarticon"><span class="num">10</span><i class="gsprite gicon cart"></i></span>
					<span class="t">购物车</span>
				</a>
			</div>
		</div>
	</div>
	<div class="mem_con">
		<div class="mem_left">
			<div id="mem_photo"><img src="http://www.12301.cc/shops/images/gggulang1.jpg" alt=""/></div>
			<ul>
				<li>个人资料</li>
				<li>修改密码</li>
				<li>订单查询</li>
				<li>安全退出</li>
			</ul>
		</div>
		<div class="mem_right">
			<div id="" class="hcon">
    <table class="proTable fixed " ><!-- id="tbl_evlt" -->
        <thead id="proTableHead">
            <tr>
                <th class="col_1">订单号</th>
                <th class="col_2">产品信息</th>
                <th class="col_3">取票人信息</th>
                <th class="col_4">订单状态</th>
                <th class="col_5">总金额</th>
                <th class="col_6">操作</th>
            </tr>
        </thead>
        <tbody>
			<!-- 第1个产品 -->
			<?
			foreach($r as $row):
				$childNum = count($row['childOrder']);
                $orderid=(string)$row['mainOrder']->UUordernum;
                // $sql = "select id from uu_discuss where orderid='$orderid' limit 1";
                // $GLOBALS['le']->query($sql);
                // $GLOBALS['le']->fetch_assoc();
                // $commentId = $le->f('id');
			?>
			<tr class="listHead">
				<td colspan="8">
					<div>
                    <a href="" title="<?=(string)$row['mainOrder']->UUltitle?>" class="title" ><?=(string)$row['mainOrder']->UUltitle?></a>
                    <p class="rt">
                        <span class="span">下单时间：<?=(string)$row['mainOrder']->UUordertime?></span>
                        <span class="span">有效期：<?=(string)$row['mainOrder']->UUbegintime?> 至 <?=(string)$row['mainOrder']->UUendtime?></span>
                        <span class="span span3">验证时间：<?=(string)$row['mainOrder']->UUdtime!="0000-00-00 00:00:00"?(string)$row['mainOrder']->UUdtime:"未验证"?></span>
                    </p>
					</div>
				</td>
			</tr>
			<tr class="listBody <?if(!$childNum)echo 'borderBottom';?>" >
				<td class="col_1 col codeNum" rowspan="<?=$childNum + 1?>">
                <?if(isMainOrder($row['mainOrder']->UUconcat_id)):?>
				<span  id="getCode"></span>
                <a href="" class="ordernb"><?=(string)$row['mainOrder']->UUordernum?></a>
                <input type="button" class="getCode" value="获取凭证号" data="<?=(string)$row['mainOrder']->UUordernum?>"/>
                <?else:?>
				<span  id="getCode"></span>
                <a  href="" class="ordernb"><?=(string)$row['mainOrder']->UUordernum?></a>
                <input type="button" class="getCode" value="获取凭证号" data="<?=(string)$row['mainOrder']->UUordernum?>"/>
                <?endif;?>
                <?if((string)$row['mainOrder']->UUremotenum){?>
				<span class="f_orderNum"><?=(string)$row['mainOrder']->UUremotenum?></span>
				<?}?>
				</td>
				<td class="col_2 col">
				【<?=(string)$row['mainOrder']->UUttitle?>】<span class="numPrice"> * <i><?=(string)$row['mainOrder']->UUtnum?></i> 张 * &yen;<i><?=(string)$row['mainOrder']->UUtprice/100?></i></span>
				</td>
				<td class="col_3 col" rowspan="<?=$childNum + 1?>">
					<p class="name2"><?=(string)$row['mainOrder']->UUordername?></p>
					<p class="tell"><?=(string)$row['mainOrder']->UUordertel?></p>
				</td>
				<td class="col_6 col" rowspan="<?=$childNum + 1?>">
				<span rowspan="<?=$row['totalOrder']?>">
                    <p>
                        <?=$uuStatus[(string)$row['mainOrder']->UUstatus]?>
                        <?if((string)$row['mainOrder']->UUstatus==2 && (string)$row['mainOrder']->UUpaystatus==2) echo '<br/><span style="color:red;">(未支付)</span>';?>
                    </p>
                    <p class="green">
					<?if($row['mainOrder']->UUstatus==0){?>
					<?=OrderRecord::$paystatusT[(string)$row['mainOrder']->UUpaystatus]?>
					<?}?>
					</p>
				</td>
				<td class="col_7 col" rowspan="<?=$childNum + 1?>">

                <?if(!isMainOrder($row['mainOrder']->UUconcat_id)):?>
                合计<span class="totalPrice">&yen;<i><?=((int)$row['mainOrder']->UUtprice*(int)$row['mainOrder']->UUtnum)/100?></i></span>
                <?else:?>
                <?
                    $total = 0;
                    foreach($row['childOrder'] as $cr){
                        // $total = $total + (string)$cr['totalPrice']/100 ;
                        $total = $total + ((int)$cr->UUtprice*(int)$cr->UUtnum)/100;
                    }
                    $total += ((int)$row['mainOrder']->UUtprice*(int)$row['mainOrder']->UUtnum)/100;
                ?>
                合计<span class="totalPrice">&yen;<i><?=$total?></i></span>
                <?endif;?>
				</td>
				<td class="col_8 col" rowspan="<?=$childNum + 1?>">
				<?
                    $ordernum = (string)$row['mainOrder']->UUordernum;// 订单号
                    if((string)$row['orderAlipay']){ // 支付
                        echo '<a href="http://yd.12301.cc/client/alipayOrder_c.html?ordernum='.$ordernum.'" target="_blank">支付</a>';
                    }elseif($row['mainOrder']->UUstatus==0){// 退票
                        echo '<a href="http://yd.12301.cc/call/handle.php?from=order_cancel&ordernum='.$ordernum.'" target="_blank">退票</a>';
                    }
                    // if($commentId){ // 是否评论
                        // echo "已评论";
                    // }elseif((string)$row['mainOrder']->UUstatus=="1"){
                        // echo  '<a href="javascript:showBg1('.$ordernum.');">点评</a>';
                    // }
                ?>
				</td>
			</tr>
			
			<?foreach($row['childOrder'] as $cr):?>
			<tr class="listBody borderBottom borderTop">
				<td class="col_2 col">
					【<?=(string)$cr->UUttitle?>】
					<span class="numPrice"> * <i><?=(string)$cr->UUtnum?></i> 张 * &yen;<i><?=(string)$cr->UUtprice/100?></i></span>
				</td>
			</tr>
			<?endforeach;//子票?>
			<tr class="marTop"><td colspan="8"></td></tr>
			<?endforeach;?>
		</tbody>
    </table>
    <?page($count,$currentPage,$pageSize,$order,$by);?>
</div>
</div>	
		
		</div>
	
	
	
	
	</div> 
	<script>
			
$(function(){
        jQuery(window).load(function(){ 
        var h = $(".right").height();
        $(".bh").css({
        height:h+"px",
        });
        //alert(h);
    });
});

		
		
function showBg1(id) { 
	var bh = $("body").height(); 
	var bw = $("body").width(); 
    $("#orderid").val(id);
	$("#fullbg1").css({ 
		height:bh, 
		width:bw, 
		display:"block" 
	}); 
	$("#dialog1").show(); 
} 
function closeBg1() { 
    $("#fullbg1,#dialog1").hide(); 
} 


window.onload=function(){
    $("#t_dian").click(function(){
        var val = $(".dianping").val(),method=$(".method").val();
       if(val==''){
            alert('您还尚未填写评论');
            return false;
        }
        $.getJSON("http://yd.12301.cc/call/discuss.php",{method:'fabu',orderid:$("#orderid").val()}).done(function(res){
            if(res.status=='200') {
                 alert("点评成功"); 
                 window.location.reload(); 
             }else {
                 alert("评论失败");
             }
        });
        return false;
    });
}

	$(function(){
	$(".getCode").click(function(){
       // alert($(".getCode").length);
       // alert($(".codeNum").length);
        //index = $(".getCode").index($(this));     
		//alert(index);
        var orderId= $(this).attr("data");
		$.ajax({
            "url":"http://www.12301.cc/call/handle.php?from=orderView&act=getCode&ordernum="+orderId,
            "dataType":"json",
            "success":function(json){
				alert(json.msg);
               // $("#getCode").html(json.msg);
                //$(".codeNum").eq(index).html(json.msg);
                //$("#getCode").css({"font-weight":"bold","color":"#FF0000"});
            }
        })
	})
});
</script>
</body>
</html>
<!--评论遮罩-->
<div id="fullbg1"></div> 
<div id="dialog1"> 

<p class="close"><span class="p_titile">评论</span>
<a href="#" onclick="closeBg1();">关闭</a>  
<div >
<form action="#" method="post">
	<textarea id="comment_textarea" name="dianping" cols="30" class="dianping" rows="10"></textarea>
	<input type="hidden" name="orderid" value="" id="orderid">
	<input type="hidden" name="method" value="fabu" class="method" />
    <input type="submit" tabindex="6" value="提交评论"  class="btn" id="t_dian" /> 
</form>
</div>
</div>